#include <stdio.h>

int main(int argc, char *argv[])
{
	int a,n,b,c;
	scanf("%d%d",&a,&n);
	b=a;
	if(n==0)printf("The last 3 numbers is 1.\n");
	
	if(n==1)
		{
			c=a%1000;
			printf("The last 3 numbers is %d.\n",c);
		}
	if(n>=2)
	{
		for(int i=2;i<=n;i++)
			{
				a=a*b;
				a=a%1000;
			}
		
			if(a<10)printf("The last 3 numbers is 00%d.\n",a);
			else if(a<100)printf("The last 3 numbers is 0%d.\n",a);
			else printf("The last 3 numbers is %d.\n",a);
		
	}
}